package com.zzh.lib.xpopup.ea;


import com.zzh.lib.views.adapter.holder.HSuperViewHolder;

import java.util.List;

/**
 * Created by ZZH on 2022/12/8.
 *
 * @Date: 2022/12/8
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description:
 */
public abstract class EasyAdapter<T> extends MultiItemTypeAdapter<T> {

    public EasyAdapter(List<T> data, int layoutResId) {
        super(data);
        addItemDelegate(new ItemDelegate<T>() {
            @Override
            public int getLayoutId() {
                return layoutResId;
            }

            @Override
            public boolean isThisType(T item, int position) {
                return true;
            }

            @Override
            public void bind(HSuperViewHolder holder, T item, int position) {
                EasyAdapter.this.bind(holder, item, position);
            }

            @Override
            public void bindWithPayloads(HSuperViewHolder holder, T item, int position, List<Object> payloads) {
                EasyAdapter.this.bindWithPayloads(holder, item, position, payloads);
            }
        });
    }

    protected abstract void bind(HSuperViewHolder holder, T t, int position);

    protected void bindWithPayloads(HSuperViewHolder holder, T t, int position, List<Object> payloads) {
        bind(holder, t, position);
    }
}
